<?php

require_once('../../func.php');
require_once('oss_php_sdk/demo/sample_base.php');

$endpoint = SampleUtil::get_endpoint();
$bucket = SampleUtil::get_bucket_name();
$oss = SampleUtil::get_oss_client();

$object = preg_replace('/\//', '-', preg_replace('/upload\//', '', $info['url']));
$file_path = $info['url'];
$options = array();

$res = $oss->upload_file_by_file($bucket, $object, $file_path, $options);
do_rmdir(preg_replace('/\/[^\/]*\..*/', '', $info['url']));

//如果定义了OSS_URL
if ($config['OSS_URL']) $info['url'] = 'http://'.$config['OSS_URL'].'/'.$object;
else $info['url'] = 'http://'.$bucket.'.'.preg_replace('/-internal/', '', $endpoint).'/'.$object;
